package cn.xzc.job.pojo;

import java.util.Objects;

/**
 * @author 熊志聪
 * @Classname Job
 * @Description 定时任务中具体要执行的任务
 * 重写equals和hasCode方法【作为map的key使用】
 * @Date 2024/2/12 20:13
 */
public class Job {
    private final Runnable runnable;

    public Job(Runnable runnable) {
        this.runnable = runnable;
    }

    public Runnable getRunnable() {
        return runnable;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Job)) {
            return false;
        }
        Job job = (Job) o;
        return Objects.equals(runnable, job.runnable);
    }

    @Override
    public int hashCode() {
        return Objects.hash(runnable);
    }


    @Override
    public String toString() {
        return this.runnable.toString();
    }
}
